<!DOCTYPE html>
<html>
<head>
    <title>首页</title>
    <meta charset="utf-8">
    <script type="text/javascript" src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
    <style type="text/css">
        .hello{
            color: #428bca;
        }
    </style>
</head>
<body>
    <h3>这是index页面</h3>
 
    <span class="hello">你可以点击这里</span>
 
    <script type="text/javascript">
        $(function(){
            var contextPath = 'http://localhost:3000';
            $('.hello').on('click',function(){
                $.ajax({
                    type:'get',
                    data:'click',
                    url:contextPath+'/api/hello',
                    success:function(data){
                        console.log("请求到数据",data);
                    },
                    error:function(data){
                        console.log(data);
                    }
 
                })
            })
        })
    </script>
 
</body>
</html>